package com.deyuanyun.pic.settings.service.base.impl;

import com.deyuanyun.pic.settings.domain.base.BizThreshold;
import com.deyuanyun.pic.settings.domain.base.BizThresholdExample;
import com.deyuanyun.pic.settings.mapper.base.BizThresholdMapper;
import com.deyuanyun.pic.settings.mapper.base.CustomBizThresholdMapper;
import com.deyuanyun.pic.settings.service.base.BizThresholdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class BizThresholdServiceImpl implements BizThresholdService {

    @Autowired
    private CustomBizThresholdMapper customBizThresholdMapper;

    @Autowired
    private BizThresholdMapper bizThresholdMapper;

    @Override
    public BizThreshold selectByPrimaryKey(String id) {
        return bizThresholdMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteByPrimaryKey(String id) {
        return bizThresholdMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(BizThreshold record) {
        return bizThresholdMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(BizThreshold record) {
        return bizThresholdMapper.updateByPrimaryKey(record);
    }

    @Override
    public int insert(BizThreshold record) {
        return bizThresholdMapper.insert(record);
    }

    @Override
    public int insertSelective(BizThreshold record) {
        return bizThresholdMapper.insertSelective(record);
    }

    @Override
    public int updateSystemChildInfo(String parentId) {
        return customBizThresholdMapper.updateRestoreSettings(parentId);
    }

    @Override
    public BizThreshold querySysByType(String type) {
        BizThresholdExample bizThresholdExample = new BizThresholdExample();
        bizThresholdExample.setDistinct(false);
        bizThresholdExample.createCriteria().andIsSysEqualTo((short) 1).andDeletedEqualTo((short) 0).andTypeEqualTo(type);
        List<BizThreshold> list = bizThresholdMapper.selectByExample(bizThresholdExample);
        return list != null && list.size() == 1 ? list.get(0) : null;
    }
}
